import QtQuick 2.0
import QtMultimedia 5.0

import '../fileTypeGetter.js' as FileTypeGetter

Item {
    property string source: ''

    onSourceChanged: {
        if (source == '' || source == null || source == undefined) {
            visible = false;
            return;
        }

        var fileType = FileTypeGetter.getFileType(source);

        if (fileType == 'image') {
            img.source = source;
            img.visible = true;
            visible = true;
            return;
        }

        visible = false;
    }

    Rectangle {
        id: background
        anchors.fill: parent
        color: 'black'
        opacity: .9

        Rectangle {
            id: quit
            height: 25
            width: 25
            anchors.right: background.right
            anchors.top: background.top
            color: 'green'


            Image {
                source: "cross.png"
                anchors.fill: parent
                visible: true
            }

            /*MouseArea {
                anchors.fill: parent
                onClicked: {


                }
            }*/

        }
    }

    Image {
        id: img
        fillMode: Image.PreserveAspectFit
        anchors.fill: parent
        visible: false
    }

    /*MediaPlayer {
        id: video
            width : 800
            height : 600
            source: "video.avi"

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    video.play()
                }
            }
    }*/
}
